package com.gitee.wsl.common.ui.ext.shape

import androidx.annotation.IntRange
import androidx.compose.foundation.shape.AbsoluteCutCornerShape
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp


fun Shapes.roundedCorner(topStart: Dp = 0.dp,
                         topEnd: Dp = 0.dp,
                         bottomEnd: Dp = 0.dp,
                         bottomStart: Dp = 0.dp) = RoundedCornerShape(topStart, topEnd, bottomEnd, bottomStart)

fun Shapes.roundedCorner(topStart: Float = 0.0f,
                         topEnd: Float = 0.0f,
                         bottomEnd: Float = 0.0f,
                         bottomStart: Float = 0.0f) = RoundedCornerShape(topStart, topEnd, bottomEnd, bottomStart)


fun Shapes.roundedCorner(@IntRange(from = 0, to = 100)
                         topStartPercent: Int = 0,
                         @IntRange(from = 0, to = 100)
                         topEndPercent: Int = 0,
                         @IntRange(from = 0, to = 100)
                         bottomEndPercent: Int = 0,
                         @IntRange(from = 0, to = 100)
                         bottomStartPercent: Int = 0) = RoundedCornerShape(topStartPercent, topEndPercent, bottomEndPercent, bottomStartPercent)

fun Shapes.cutCorner(topStart: Dp = 0.dp,
                     topEnd: Dp = 0.dp,
                     bottomEnd: Dp = 0.dp,
                     bottomStart: Dp = 0.dp) = CutCornerShape(topStart, topEnd, bottomEnd, bottomStart)

fun Shapes.cutCorner(topStart: Float = 0.0f,
                     topEnd: Float = 0.0f,
                     bottomEnd: Float = 0.0f,
                     bottomStart: Float = 0.0f) = CutCornerShape(topStart, topEnd, bottomEnd, bottomStart)


fun Shapes.cutCorner(@IntRange(from = 0, to = 100)
                     topStartPercent: Int = 0,
                     @IntRange(from = 0, to = 100)
                     topEndPercent: Int = 0,
                     @IntRange(from = 0, to = 100)
                     bottomEndPercent: Int = 0,
                     @IntRange(from = 0, to = 100)
                     bottomStartPercent: Int = 0) = CutCornerShape(topStartPercent, topEndPercent, bottomEndPercent, bottomStartPercent)


fun Shapes.absoluteRoundedCorner(topStart: Dp = 0.dp,
                                 topEnd: Dp = 0.dp,
                                 bottomEnd: Dp = 0.dp,
                                 bottomStart: Dp = 0.dp) = AbsoluteRoundedCornerShape(topStart, topEnd, bottomEnd, bottomStart)

fun Shapes.absoluteRoundedCorner(topStart: Float = 0.0f,
                                 topEnd: Float = 0.0f,
                                 bottomEnd: Float = 0.0f,
                                 bottomStart: Float = 0.0f) = AbsoluteRoundedCornerShape(topStart, topEnd, bottomEnd, bottomStart)


fun Shapes.absoluteRoundedCorner(@IntRange(from = 0, to = 100)
                                 topStartPercent: Int = 0,
                                 @IntRange(from = 0, to = 100)
                                 topEndPercent: Int = 0,
                                 @IntRange(from = 0, to = 100)
                                 bottomEndPercent: Int = 0,
                                 @IntRange(from = 0, to = 100)
                                 bottomStartPercent: Int = 0) = AbsoluteRoundedCornerShape(topStartPercent, topEndPercent, bottomEndPercent, bottomStartPercent)


fun Shapes.absoluteCutCorner(topStart: Dp = 0.dp,
                             topEnd: Dp = 0.dp,
                             bottomEnd: Dp = 0.dp,
                             bottomStart: Dp = 0.dp) = AbsoluteCutCornerShape(topStart, topEnd, bottomEnd, bottomStart)

fun Shapes.absoluteCutCorner(topStart: Float = 0.0f,
                             topEnd: Float = 0.0f,
                             bottomEnd: Float = 0.0f,
                             bottomStart: Float = 0.0f) = AbsoluteCutCornerShape(topStart, topEnd, bottomEnd, bottomStart)


fun Shapes.absoluteCutCorner(@IntRange(from = 0, to = 100)
                             topStartPercent: Int = 0,
                             @IntRange(from = 0, to = 100)
                             topEndPercent: Int = 0,
                             @IntRange(from = 0, to = 100)
                             bottomEndPercent: Int = 0,
                             @IntRange(from = 0, to = 100)
                             bottomStartPercent: Int = 0) = AbsoluteCutCornerShape(topStartPercent, topEndPercent, bottomEndPercent, bottomStartPercent)

